package biblioteca.servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import biblioteca.dao.BibliotecaDAO;
import biblioteca.dao.exceptions.BibliotecaDAOException;
import biblioteca.dao.impl.BibliotecaDAOImp;
import biblioteca.modelo.Libro;

/**
 * Servlet implementation class Prueba
 */
public class Prueba extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BibliotecaDAO dao=(BibliotecaDAO) request.getSession().getServletContext().getAttribute("dao");		
		List<Libro> libros;
		
		try {
			libros = dao.obtenerLibros();
			System.out.println(libros);
			request.setAttribute("libros", libros);
			request.getRequestDispatcher("/pruebasEtiquetas.jsp").forward(request, response);
		} catch (BibliotecaDAOException e) {			
			e.printStackTrace();
		}
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
